<?php
require("../../class/connect.php");
include("../../class/db_sql.php");
include("../../class/config.php");
include("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=(int)$_GET['userid'];
$loginin=$_GET['username'];
$loginrnd=$_GET['rnd'];
$classid=(int)$_GET['classid'];
$filepass=(int)$_GET['filepass'];
$type=$_GET['type'];
$doing=$_GET['doing'];
$editor=1;
is_login($logininid,$loginin,$loginrnd);
db_close();
$empire=null;
?>
<html>
<head>
<title>插入图片</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<style type="text/css">
html, body {
  background: ButtonFace;
  color: ButtonText;
  font: 11px Tahoma,Verdana,sans-serif;
  margin: 0px;
  padding: 0px;
}
body { padding: 5px; }
table {
  font: 11px Tahoma,Verdana,sans-serif;
}
form p {
  margin-top: 5px;
  margin-bottom: 5px;
}
.fl { width: 6em; float: left; padding: 2px 5px; text-align: right; }
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; }
fieldset { padding: 0px 10px 5px 5px; }
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
button { width: 70px; }
.space { padding: 2px; }

.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px;
border-bottom: 1px solid black; letter-spacing: 2px;
}
form { padding: 0px; margin: 0px; }
</style>
<script type="text/javascript">
//返回编号
function ExpStr(str,exp){
	var pos,len,ext;
	pos=str.lastIndexOf(exp)+1;
	len=str.length;
	ext=str.substring(pos,len);
	return ext;
}
function ReturnFileNo(obj){
	var filename,str,exp;
	if(obj.no.value!='')
	{
		return '';
	}
	if(obj.file.value!='')
	{
		str=obj.file.value;
	}
	else
	{
		str=obj.tranurl.value;
	}
	if(str.indexOf("\\")>=0)
	{
		exp="\\";
	}
	else
	{
		exp="/";
	}
	filename=ExpStr(str,exp);
	obj.no.value=filename;
}

//提交
function CheckDoing(obj,ecms){
	if(obj.tranurl.value!=''||obj.file.value!='')
	{
		ReturnFileNo(obj);
		return true;
	}
	if(obj.inserturl.value!='')
	{
		SetThePicOk(obj,ecms);
	}
	return false;
}

//返回图片
function SetThePicOk(obj,ecms){
	var picurl=obj.inserturl.value;
	var picsay=obj.pic_say.value;
	var piclink=obj.pic_link.value;
	var piclinktarget=obj.pic_linktarget.value;
	var height=obj.pic_height.value;
	var width=obj.pic_width.value;
	var border=obj.pic_border.value;
	var picalt=obj.pic_alt.value;
	var vspace=obj.pic_vspace.value;
	var hspace=obj.pic_hspace.value;
	var picalign=obj.pic_align.value;
	var addjs=0,imgstr="";
	imgstr="<img src='"+picurl+"'";
	if(obj.pic_autosize.checked)
	{
		addjs=1;
		imgstr+=" onload=\"autosimg(this);\" onmousewheel=\"return zoomimg(this);\"";
	}
	if(!(height==""||height==0))
	{
		imgstr+=" height="+height;
	}
	if(!(width==""||width==0))
	{
		imgstr+=" width="+width;
	}
	if(border!='')
	{
		imgstr+=" border="+border;
	}
	if(picalt!='')
	{
		imgstr+=" alt='"+picalt+"'";
	}
	if(vspace!='')
	{
		imgstr+=" vspace="+vspace;
	}
	if(hspace!='')
	{
		imgstr+=" hspace="+hspace;
	}
	if(picalign!='')
	{
		imgstr+=" align="+picalign;
	}
	if(piclink=='')
	{
		piclink=picurl;
	}
	imgstr="<a href='"+piclink+"' target='"+piclinktarget+"'>"+imgstr+"></a>";
	if(picsay!="")
	{
		imgstr+="<br><span style='line-height=18pt'>"+picsay+"</span>";
	}
	if(picalign=='center')
	{
		imgstr='<center>'+imgstr+'</center>';
	}
	if(ecms==0)
	{
		document.getElementById('viewpic').innerHTML=imgstr;
	}
	else
	{
		window.opener.DoFile(imgstr);
		window.close();
	}
}

//预览图片
function DoViewPic(obj)
{
	if(!obj)
	{
		return;
	}
	if(obj.value!=''&&obj.value!=null)
	{
		document.getElementById('viewpic').src=obj.value;
		document.getElementById('viewpiclink').href=obj.value;
	}
}

//图片地址转换
function ChangePicUrlTb(url){
	if(url==1)
	{
		insertpictb.style.display="none";
		tranpictb.style.display="";
	}
	else
	{
		insertpictb.style.display="";
		tranpictb.style.display="none";
	}
}
</script>
</head>
<body>
  <table width="100%" border="0" cellspacing="1" cellpadding="3">
  <form action="<? echo"../enews.php?userid=$logininid&username=$loginin&rnd=$loginrnd";?>" method="post" enctype="multipart/form-data" name="etranimgform" onsubmit="return CheckDoing(document.etranimgform,1);">
  	<input type=hidden name=classid value="<?=$classid?>">
	<input type=hidden name=filepass value="<?=$filepass?>">
    <input type=hidden name=enews value="TranFile">
    <input type=hidden name=type value="1">
    <input type=hidden name=doing value="0">
	<input type=hidden name=tranfrom value="1">
    <tr>
      <td>
	   <fieldset>
        <legend>图片地址: &nbsp;[<a href="#ecms" onclick="ChangePicUrlTb(0);document.etranimgform.inserturl.focus();"><font color="#0000FF">插入图片</font></a>]&nbsp;&nbsp;&nbsp;[<a href="#ecms" onclick="ChangePicUrlTb(1);document.etranimgform.file.focus();"><font color="#0000FF">上传图片</font></a>]</legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="3" id="insertpictb">
          <tr>
            <td>图片地址：<input type="text" id="txtUrl" name="inserturl" size="32" onchange="DoViewPic(this);" />
              <input type="button" name="Submit2" value="选择" onclick="window.open('<?="file.php?userid=$logininid&username=$loginin&rnd=$loginrnd&filepass=$filepass&classid=$classid&type=1&tranfrom=1&field=opener.document.etranimgform.inserturl";?>','','width=700,height=550,scrollbars=yes');"></td>
          </tr>
        </table>
		
		<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" id="tranpictb" style="display=none">
          <tr> 
            <td width="78%">远程保存：<input name="tranurl" type="text" id="tranurl" size="32" onchange="DoViewPic(this);"></td>
          </tr>
          <tr> 
            <td>本地上传：<input type="file" name="file" onchange="DoViewPic(this);"> <input name="getmark" type="checkbox" id="getmark" value="1"> 
              <a href="../SetEnews.php" target="_blank">加水印</a></td>
          </tr>
          <tr> 
            <td>上传选项：<input name="getsmall" type="checkbox" id="getsmall" value="1">
              生成缩略图：宽度: 
              <input name="width" type="text" id="width" value="<?=$public_r['spicwidth']?>" size="6">
              * 高度: 
              <input name="height" type="text" id="height" value="<?=$public_r['spicheight']?>" size="6"></td>
          </tr>
          <tr> 
            <td>文件编号：<input name="no" type="text" id="no" value="<?=$_GET['fileno']?>" size="32"> 
              </td>
          </tr>
          <tr> 
            <td><font color="#666666">(说明：本地比远程优先.)</font></td>
          </tr>
        </table>
        </fieldset>
	  </td>
    </tr>
    <tr>
      <td><fieldset><legend>显示效果</legend>
	    <table cellspacing="1" cellpadding="3" border="0" width="100%" height="100%">
          <tr>
			<td>图片说明：<input type="text" name="pic_say" size="32" />
              <font color="#666666"> (显示在图片下面)</font></td>
		</tr>
		<tr>
			<td>
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>图片链接：<input name="pic_link" type="text" id="txtLnkUrl" size="32" /></td>
                  <td><select id="cmbLnkTarget" name="pic_linktarget">
						<option value="">不设置</option>
						<option value="_blank" selected>新窗口 (_blank)</option>
						<option value="_top">整页 (_top)</option>
						<option value="_self">本窗口 (_self)</option>
						<option value="_parent">父窗口 (_parent)</option>
					</select></td>
                </tr>
              </table> </td>
		</tr>
		<tr height="100%">
			<td valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td>图片宽度：<input type="text" size="5" id="txtWidth" name="pic_width" /></td>
                  <td>图片高度：<input type="text" size="5" id="txtHeight" name="pic_height" />
                    自动缩放
                    <input type="checkbox" name="pic_autosize" value="1"></td>
                </tr>
                <tr> 
                  <td>边框粗细：<input name="pic_border" type="text" id="txtBorder" size="5" value="0" /></td>
                  <td>替代文字：<input type="text" id="txtAlt" name="pic_alt" /></td>
                </tr>
                <tr>
                  <td>上下间距：<input name="pic_vspace" type="text" id="txtVSpace" size="5" /></td>
                  <td>左右间距：<input name="pic_hspace" type="text" id="txtHSpace" size="5" /></td>
                </tr>
                <tr> 
                  <td>对齐方式：<select name="pic_align" id="cmbAlign">
						  <option value="" selected>默认</option>
						  <option value="right">右对齐</option>
						  <option value="center">居中</option>
						  <option value="left">左对齐</option>
						  <option value="top">顶端</option>
						  <option value="bottom">底边</option>
						  <option value="absBottom">绝对底边</option>
						  <option value="absMiddle">绝对居中</option>
						  <option value="baseline">基线</option>
						  <option value="textTop">文本上方</option>
						</select></td>
                  <td><div align="right">
                      <input type="submit" name="Submit3" value=" 确 定 ">
                      &nbsp; 
                      <input type="button" name="Submit4" value="取消" onclick="window.close();">
                    </div></td>
                </tr>
              </table>
              
            </td>
		</tr>
	</table>
	  </fieldset>
	  </td>
    </tr>
    <tr>
      <td><fieldset><legend>预览图片</legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr>
            <td><div align="center"><a href="popups/addimg/notimg.gif" target="_blank" id="viewpiclink"><img name="viewpic" id="viewpic" src="popups/addimg/notimg.gif" width="160" height="120" alt="预览图片" border="0"></a></div></td>
          </tr>
        </table>
        </fieldset>
	  </td>
    </tr>
	</form>
  </table>
</body>
</html>